package com.huobi.db.mapper;

import java.util.List;

import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import com.huobi.db.bean.PlaceInfo;
import com.huobi.db.bean.TradeOrder;

@Mapper
public interface TradeOrderMapper {

	public List<TradeOrder> selectByStatus(String value);

	@Update("update ls_trade_order set status = 'pending' where id = #{id} and status = 'waiting'")
	public int updateToPending(String id);

	@Update("update ls_trade_order set status = 'waiting' where id = #{id} and status = 'pending'")
	public void updateToWaiting(String id);

	@Select("select * from ls_trade_order where status = #{status} order by id desc limit 1")
	public TradeOrder getLastTradeOrder(String status);

	public void save(TradeOrder order);

	@Select("select * from ls_trade_order where id = #{id}")
	public TradeOrder findById(String id);

	@Update("update ls_trade_order set status = 'failed' where id = #{id} and status = 'waiting'")
	public void updateToFailed(String id);

	public void updateInfo( PlaceInfo placeInfo);

	@Update("update ls_trade_order set status = 'p_succed' where id = #{id} and status in( 'waiting','pending')")
	public void updateToPSucced(String id);

}
